#ifndef MCPRO_H
#define MCPRO_H
#include "MC.h"
#include <memory>
#define UNREFERENCED_PARAMETER(x) (&x) 
extern volatile _mch kmemory;
template<typename T>
static unsigned int* _KMALLOC(T size)
{
  return (unsigned int*)(Kmalloc((_mch*)&kmemory,size));
}
template<typename T>
static void _KRELEASE(T* pointer)
{
  Kfree((_mch*)&kmemory,pointer);
}


template <typename T>
class MemoryAllocator 
{public:
  typedef T value_type;
  typedef T* pointer;
  typedef const T* const_pointer;
  typedef T& reference;
  typedef const T& const_reference;
  typedef size_t size_type;
  typedef ptrdiff_t difference_type;

  template <class U>
  struct rebind
  {
   typedef  MemoryAllocator<U> other;
  };

  pointer allocate(size_type n, const void* hint = 0)
  {
	UNREFERENCED_PARAMETER(hint);
	if(n <= 0 || n >max_size())
		return nullptr;
	return (pointer)_KMALLOC(n);
  }
  void deallocate(pointer p, size_type n)
  {
	UNREFERENCED_PARAMETER(n);
	_KRELEASE(p);
  }
  void construct(pointer p, const T& value)
  {
	::new(p) T(value);
  }
  void destroy(pointer p)
  {
	p->~T();
  }

  pointer address(reference x)
  {
	return (pointer)(&x);
  }

  const_pointer const_address(const_reference x)
  {
	return (const_pointer)(&x);
  }

  size_type max_size() const
  {
  }
};
#endif
